#include "../header.h"

int main(int argc, char const *argv[])
{
    fd_set reset = {0};
    struct timeval tm = {0};
    char buf[256] = "";
    int count = 0;
    // 设置超时时间为3秒
    while(strncmp(buf, "exit", 5))
    {
        FD_SET(STDIN_FILENO, &reset);
        tm.tv_sec = 3;
        count = select(STDIN_FILENO + 1, &reset, NULL, NULL, &tm);
        printf("时间到 count= %d\n",count);
        if(FD_ISSET(STDIN_FILENO, &reset))
        {
            printf("键盘有数据变化\n");
            bzero(buf, sizeof(buf));
            read(STDIN_FILENO, buf, sizeof(buf));
            printf("读到的数据为: %s\n", buf);
        }

    }
    
    return 0;
}
